/*
 * Class ItemOperate
 *
 * Version 1.0
 *
 * Thursday, August 21, 2008
 *
 * Created by Palidino76
 */

package palidino76.rs2.io.packets;


import palidino76.rs2.*;
import palidino76.rs2.player.Player;
import palidino76.rs2.util.Misc;

public class ItemOperate implements Packet {
    /**
     * Handles operating equipped items.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        int junk = p.stream.readDWord();
        int itemId = p.stream.readUnsignedWordA();
        int itemSlot = p.stream.readUnsignedWordBigEndianA();
        if (itemSlot < 0 || itemSlot >= p.equipment.length || p.equipment[itemSlot] != itemId) {
            return;
        }
        switch (itemId) {
		case 7927:
		p.npcType = 3690;
		p.appearanceUpdateReq = true;
		p.updateReq = true;
		break;

		case 8007:
		Engine.playerItems.deleteItem(p, 8007, itemSlot, 1);
		p.teleportTo(3212, 3428, 0, 4, 0, 9012, 9013, 0, 0, 0, 0);
		p.summonTeleDelay = 3;
		break;

		case 1702:
		case 1704:
		case 1706:
		case 1708:
		case 1710:
			p.requestGFX(301, 100);
			p.requestAnim(714, 0);
			p.summonTeleDelay = 4;
		break;

        default:
            Misc.println("[" + p.username + "] Operate item: " + itemId);
            break;
        }
    }
}
